package com.yuexun.dhdoctor.module.mythings.presenter.impl;



import com.yuexun.dhdoctor.module.mythings.bean.TaskListData;
import com.yuexun.dhdoctor.module.mythings.model.IThingModel;
import com.yuexun.dhdoctor.module.mythings.presenter.IThingPresenter;
import com.yuexun.dhdoctor.module.mythings.ui.view.IThingsView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/8/31.
 */
public class ThingPresenter implements IThingPresenter {
    private IThingsView view;
    private IThingModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public ThingPresenter(IThingModel model, IThingsView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void getOtherTaskDatas(Map<String, String> praise) {
        model.getOtherTaskDatas(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<TaskListData>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(TaskListData taskListData) {
                        view.showOtherTaskDatas(taskListData);
                    }
                });
    }

    @Override
    public void getCopyTaskDatas(Map<String, String> praise) {
        model.getCopyTaskDatas(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<TaskListData>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(TaskListData taskListData) {
                        view.showOtherTaskDatas(taskListData);
                    }
                });
    }
}
